<div class="posts view">
<div class="widget" id="widget_post_view" style="width: 96%">
    <div class="toggle">&nbsp;</div>
    <h3 class="handle"><?php __('View Post');?></h3>
    <div class="content">
        <div class="post">
            <h3 class="title"><?php e($post['Post']['title']); ?></h3>
            <div class="meta">
                <span class="created">
                    <?php __('Published:'); ?>
                    <?php e(date('Y-m-d', strtotime($post['Post']['created']))); ?>
                </span>
                <span class="author">
                    <?php __('Author:'); ?>
                    <?php e($post['User']['username']); ?>
                </span>
                <span class="clicks">
                    <?php __('Clicks:'); ?>
                    <?php e($post['Post']['clicks']); ?>
                </span>
                <span class="attachment">
                    <?php __('Attachment Count:'); ?>
                    <?php e($post['Post']['attachment_count']); ?>
                </span>
                <?php if(!empty($user['group']) && $user['group'] != 'student'): ?>
                    <span class="edit"><?php e($html->link(__('Edit Post', true),
                        array('action' => 'edit', $post['Post']['id']))); ?></span>
                    <span class="delete"><?php e($html->link(__('Delete Post', true),
                        array('action' => 'delete', $post['Post']['id']))); ?></span>
                <?php endif; ?>
            </div>
            <div class="content"><?php e($post['Post']['content']); ?></div>
            <?php if(!empty($post['Attachment'])): 
                $attachments = $post['Attachment']; ?>
            <div class="attachments">
                <h3><?php __('Attachments'); ?></h3>
                <ul>
                <?php foreach($attachments as $i=>$item): ?>
                    <li>
                    <?php
			        if($file = $medium->file($item)){

		         		$Medium = Medium::factory($file);
				        $size = $medium->size($file);
					    $size = $number->toReadableSize($size);
                        $pieces = explode('.', $item['basename']);
                        $extension = $pieces[count($pieces)-1];
                        $name = empty($item['alternative']) ? $item['basename'] : $item['alternative'];
				        printf('<span>%s&nbsp;(%s)</span>',
						        $html->link(
						            empty($extension) ? $name : $name.'.'.$extension,
						            array('controller'=>'posts','action'=>'download', $item['id'])),
						        $size);
			        }
			        ?>
                    </li>
                <?php endforeach; ?>
                </ul>
            </div>
            <?php endif; ?>
        </div>
    </div>
</div>
<?php //unset($post['Post']); debug($post);  ?>
</div>
